package com.sinosoft.dsp.component.bpm.util;

import com.sinosoft.dsp.system.core.property.BasePropertyHandler;

public enum DeploymentFileType {
	
	// 部署
	DEPLOYMENT(
			"deployment",
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.deployment.icon"),
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.deployment.icon.expanded"),
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.deployment.icon.collapsed"),
			null, null, false),
	// 资源目录
	RESOURCE_DIRECTORY(
			"res_dir",
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.dir.icon"),
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.dir.icon.expanded"),
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.dir.icon.collapsed"),
			null, null, false),
	// 资源文件
	RESOURCE_FILE(
			"res_file",
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.file.icon"),
			null,
			null,
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.file.icon.leaf"),
			null, true),
	// JPDL资源文件
	RESOURCE_FILE_JPDL(
			"res_file_jpdl",
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.jpdl.icon"),
			null,
			null,
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.jpdl.icon.leaf"),
			new String[] { ".jpdl", ".jpdl.xml" }, true),
	// BPMN资源文件
	RESOURCE_FILE_BPMN(
			"res_file_bpmn",
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.bpmn.icon"),
			null,
			null,
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.bpmn.icon.leaf"),
			new String[] { ".bpmn", ".bpmn.xml" }, true),
	// DRL资源文件
	RESOURCE_FILE_DRL(
			"res_file_drl",
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.drl.icon"),
			null,
			null,
			BasePropertyHandler
					.getProperty("bpm.deployment.fileType.resource.drl.icon.leaf"),
			new String[] { ".drl", ".drl.xml" }, true);
	
	public static final String PREFIX_FILE = "res_file";

	private String name;

	private String largeIcon;

	private String expandedIcon;

	private String collapsedIcon;

	private String leafIcon;

	private String[] endWithes;

	private boolean isFile;

	DeploymentFileType(String name, String largeIcon, String expandedIcon,
			String collapsedIcon, String leafIcon, String[] endWithes,
			boolean isFile) {
		this.name = name;
		this.largeIcon = largeIcon;
		this.expandedIcon = expandedIcon;
		this.collapsedIcon = collapsedIcon;
		this.leafIcon = leafIcon;
		this.endWithes = endWithes;
		this.isFile = isFile;
	}

	public String getName() {
		return name;
	}

	public String getLargeIcon() {
		return largeIcon;
	}

	public String getExpandedIcon() {
		return expandedIcon;
	}

	public String getCollapsedIcon() {
		return collapsedIcon;
	}

	public String getLeafIcon() {
		return leafIcon;
	}

	public String[] getEndWithes() {
		return endWithes;
	}

	public boolean isFile() {
		return isFile;
	}

	public static DeploymentFileType getFileType(String name) {
		String[] endWithes;
		for (DeploymentFileType ft : DeploymentFileType.values()) {
			endWithes = ft.getEndWithes();
			if (endWithes != null)
				for (String ew : endWithes) {
					if (name.toLowerCase().endsWith(ew)) {
						return ft;
					}
				}
		}
		return RESOURCE_FILE;
	}

}
